#!/usr/bin/perl
#!/usr/local/bin/perl
################################
# ifconfig.pl: created by Lihy #
################################
# Use the regular expression to parse the 'ifconfig' command.

use strict;
use warnings;

my %net_addr; # the returned hash
my $net;
my $addr;

while (<STDIN>) {
  if(/\A(([a-zA-Z]|\d)+)\s/) {
    $net = $1;
  } elsif (/inet addr:((\d|[a-zA-Z]|\.)+)\s/) {
    $addr = $1;
    $net_addr{$net} = $addr;
  }
}
 # Print the hash out
while (my ($key,$value) = each %net_addr) {
  print "$key => $value\n";
}
